#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;
int w[21][21][21];

int RF(int a,int b,int c)
{
    if(a<=0 || b<=0 || c<= 0) return 1;
    else if(a>20 || b>20 || c>20) return w[20][20][20];
    else return w[a][b][c];
}

int main()
{
    freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    int n,a,b,c;
    for(a=0;a<=20;a++)
    for(b=0;b<=20;b++)
    for(c=0;c<=20;c++)
    {
        if(a==0 || b==0 || c==0) w[a][b][c]=1;
        else if(a<b && b<c) w[a][b][c]=RF(a,b,c-1)+RF(a,b-1,c-1)-RF(a,b-1,c);
        else w[a][b][c]=RF(a-1,b,c)+RF(a-1,b-1,c)+RF(a-1,b,c-1)-RF(a-1,b-1,c-1);
        //cout<<w[a][b][c]<<endl;
    }
    cin>>n;
    while(n--)
    {
        cin>>a>>b>>c;
        printf("W(%d, %d, %d) = %d\n",a,b,c,RF(a,b,c));
    }
    return 0;
}
